<template>
  <!--商品管理-退款管理 -->
  <div>
    <div>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="付款时间">
          <el-date-picker
            v-model="value1"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="付款方式">
          <el-select v-model="formInline.region" placeholder="请选择付款方式">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="商品类型">
          <el-select v-model="formInline.region" placeholder="请选择商品类型">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="订单状态">
          <el-select v-model="formInline.region" placeholder="请选择订单状态">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="买家">
          <el-input
            v-model="formInline.goodsName"
            placeholder="请输入买家姓名/ID"
          ></el-input>
        </el-form-item>
        <el-form-item label="优惠方式">
          <el-select v-model="formInline.region" placeholder="请选择优惠方式">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="searchFn()">搜索</el-button>
          <el-button type="primary" @click="addRefundShow = true"
            >新增退款</el-button
          >
        </el-form-item>
      </el-form>
      <h2>总退款：12435445.00元</h2>
    </div>
    <div>
      <el-table
        :data="tableData"
        border
        style="width: 100%"
        header-cell-class-name="thead"
      >
        <el-table-column prop="date" label="退款编号" width="180">
          <template slot-scope="scope">
            <b>11111111</b>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="关联订单" width="300">
          <template slot-scope="scope">
            <b>11111111</b>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="申请退款金额">
          <template slot-scope="scope">
            <p>七年级语文专项辅导-0001</p>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="订单实付金额">
          <template slot-scope="scope">
            <p>1200.00</p>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="申请时间">
          <template slot-scope="scope">
            <p>1800</p>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="紧急程度">
          <template slot-scope="scope">
            <p>2019.11.12 14:00</p>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="退款状态">
          <template slot-scope="scope">
            <p>2019.12.12 14:00</p>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="买家姓名">
          <template slot-scope="scope">
            <p>未上架</p>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="退款时间">
          <template slot-scope="scope">
            <p>未上架</p>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="审核人">
          <template slot-scope="scope">
            <p>未上架</p>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作">
          <template slot-scope="scope">
            <a @click="setClassHour()">审核</a>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper"
      ></el-pagination>
    </div>
    <el-dialog title="新增规格" :visible.sync="addRefundShow" width="30%">
      <div>
        <el-form ref="form" :rules="rules" :model="addForm" label-width="110px">
          <el-form-item label="买家姓名" prop="name">
            <el-input
              v-model="addForm.name"
              placeholder="请输入买家姓名"
            ></el-input>
          </el-form-item>
          <el-form-item label="关联订单" prop="order">
            <el-select v-model="addForm.order" placeholder="请选择关联订单">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="实际付款金额">
            <el-input
              v-model="addForm.amount"
              placeholder="请输入实际付款金额"
            ></el-input>
          </el-form-item>
          <el-form-item label="申请退款金额" prop="refund">
            <el-input
              v-model="addForm.refund"
              placeholder="请输入申请退款金额"
            ></el-input>
          </el-form-item>
          <el-form-item label="退款原因" prop="reason">
            <el-input
              type="textarea"
              v-model="addForm.reason"
              placeholder="请输入退款原因"
            ></el-input>
          </el-form-item>
          <el-form-item label="紧急程度" prop="level">
            <el-radio v-model="addForm.level" label="1">一般</el-radio>
            <el-radio v-model="addForm.level" label="2">紧急</el-radio>
            <el-radio v-model="addForm.level" label="3">特别紧急</el-radio>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addRefundShow = false">取 消</el-button>
        <el-button type="primary" @click="submitForm('form')">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data () {
    return {
      addForm: {
        name: '',
        order: '',
        amount: '',
        refund: '',
        reason: '',
        level: ''
      },
      rules: {
        name: [
          { required: true, message: '请输入买家姓名', trigger: 'blur' },
          { min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' }
        ],
        order: [
          { required: true, message: '请选择关联订单', trigger: 'change' }
        ],
        amount: [
          { required: true, message: '请输入实际付款金额', trigger: 'blur' }
        ],
        refund: [
          { required: true, message: '请输入申请退款金额', trigger: 'blur' }
        ],
        reason: [
          { required: true, message: '请输入退款原因', trigger: 'blur' }
        ],

        level: [{ required: true, message: '请选择紧急程度', trigger: 'blur' }]
      },
      addRefundShow: false,
      value1: '',
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      formInline: {
        user: '',
        region: ''
      },
      tableData: [
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        },
        {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        },
        {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        }
      ]
    }
  },
  methods: {
    // 表单验证
    submitForm (formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    addRefund () {},
    searchFn () {},
    addGoods () {
      this.$router.push({ name: 'add-goods' })
    },
    // 每页数
    sizeChangeHandle (val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle (val) {
      this.pageIndex = val
      this.queryPageList()
    }
  }
}
</script>
<style scoped>
a {
  cursor: pointer;
}
</style>
